﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Net;
using System.IO;
using System.Web.UI.HtmlControls;
using System.Configuration;

namespace GetData
{
    public partial class CallPostMethodInitialSetup : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               
            }
        }

        protected void btnTest_Click(object sender, EventArgs e)
        {
           
            string postData;
            HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(Convert.ToString(ConfigurationManager.AppSettings["PostUrl"]) + "getApp_Initial_Setup");
            postData = "user_name=" + txtuser_name.Text + "/password=" + txtpassword.Text + "/promo_code=" + txtpromo_code.Text + "/app_mo_alert_week=" + txtapp_mo_alert_week.Text + "/app_mo_alert_day=" + txtapp_mo_alert_day.Text + "/app_mo_alert_hour=" + txtapp_mo_alert_hour.Text + "/app_mo_alert_badge=" + txtapp_mo_alert_badge.Text + "/app_mo_alert_popup=" + txtapp_mo_alert_popup.Text + "/sentFrom=" + txtsentFrom.Text;
            
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] data = encoding.GetBytes(postData);

            httpWReq.Method = "POST";
            httpWReq.ContentType = "application/x-www-form-urlencoded";
            httpWReq.ContentLength = data.Length;

            using (Stream stream = httpWReq.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
            string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
            lblResponse.Text = responseString;
            
        }
       
    }
}